home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 09 - 1993 / 09.08 Aug 93 / Other AppleScript Samples / Simple Drop Examples / Count Files Since Started.txt < prev    next >
Encoding:
Text File  |  1993-07-02  |  1.1 KB  |  33 lines  |  [TEXT/ToyS]

  1. property icount : 0 -- this value is what is set when the script is compiled
  2. -- the property may have any value at all, depending on how many times this script as run
  3.  
  4. on increment()
  5.     set icount to icount + 1
  6. end increment
  7.  
  8. on open names
  9.     -- this is called when files are dropped on this script application
  10.     -- the first parameter (in this case “names”) contains a list of file pathnames
  11.     -- We’ll simply count and display them
  12.     repeat with i in names
  13.         increment()
  14.         display dialog "File #" & icount & " is “" & i & "”" buttons {"OK"} default button "OK"
  15.     end repeat
  16. end open
  17.  
  18. on report()
  19.     -- this handler simply displays the count of files dropped
  20.     display dialog (icount as string) & " files have been dropped since I started running." buttons {"OK"} default button "OK"
  21. end report
  22.  
  23. on quit
  24.     -- reset the counter and continue quitting
  25.     -- to bypass this, hold the shift key down when quitting
  26.     -- this is useful when you forget the continue or have bugs in your quit handler
  27.     set icount to 0
  28.     continue quit
  29. end quit
  30.  
  31. -- this statement is implicitly part of the “run” handler
  32. -- it will be called if you double click this script application directly
  33. report()